//
//  UIButton+Extension.swift
//  微博(swfit)
//
//  Created by YLW on 15/9/21.
//  Copyright © 2015年 YLW. All rights reserved.
//

import UIKit

extension UIButton{
    
    convenience init(imageName : String , backImageName : String )
    {
        self.init()
        
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        setBackgroundImage(UIImage(named: backImageName), forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: UIControlState.Highlighted)
        
        sizeToFit()
    }
    
    convenience init(imageName : String ,title : String, fontSize : CGFloat , titleColor : UIColor)
    {
        self.init()
        
        setBackgroundImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setTitle(title, forState: UIControlState.Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        setTitleColor(titleColor, forState: UIControlState.Normal)
    }
    
}
